<?php
header ("Content-type: image/png");
$diff = $_GET['diff'];
$x1=$_GET['x1'];
$x2=$_GET['x2'];
$y1=$_GET['y1'];
$y2=$_GET['y2'];

$questions = $_GET['questions'];
if($questions > 0)
{ $height = (66*($questions))-66+12; }
else
{ $height = 66+12; }

switch ($diff)
{
	case 3:
		$im = @ImageCreate (150, $height);
		break;
	case 4:
		$im = @ImageCreate (182, $height);
		break;
	case 5:
		$im = @ImageCreate (206, $height);
		break;
	case 6:
		$im = @ImageCreate (234, $height);
		break;
	case 7:
		$im = @ImageCreate (262, $height);
		break;
	default:
		$im = @ImageCreate (206, $height);
		break;
}

$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 0, 255, 0);
$text_color2 = ImageColorAllocate ($im, 0, 0, 192);

// imageline ($im,$x1,$y1,$x2,$y2,$text_color);
//imageline ($im,12,0,100,200,$text_color);
//imageline ($im,100,0,12,200,$text_color);

$y1=12;
$y2=(12+66);

for($i=1; $i<$questions; $i++)
{
	$x1=$_GET['x'.$i];
	$x2=$_GET['x'.($i+1)];
	
	imageline ($im,$x1,$y1,$x2,$y2,$text_color);
	
	if(isset($_GET['2x'.$i]))
	{
		$x1_2 = $_GET['2x'.$i];
		$x2_2 = $_GET['2x'.($i+1)];
		imageline ($im,$x1_2,$y1,$x2_2,$y2,$text_color2);
	}
	
	$y1 = $y1+66;
	$y2 = $y2+66;
}

ImagePng ($im);
?> 